<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"vchao.top","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="&gt; 物流配送页面。主要使用RecycleView实现。通过判断将条目的第一条进行特殊处理。日后复制粘贴备用。效果图如下：  可以通过各个view的相对位置来实现啊,比如那一条竖线可以用imageview来实现,那个圆点也可以用imageview实现啊,唯一不同的就是竖线的view是穿过灰色的圆view的,而position为0的竖线是不穿过蓝色的圆view的,这个也有办法搞定,在adapt">
<meta property="og:type" content="article">
<meta property="og:title" content="安卓：三分钟实现物流配送页面（时间轴效果）">
<meta property="og:url" content="http://vchao.top/2018/03/12/%E5%AE%89%E5%8D%93%EF%BC%9A%E4%B8%89%E5%88%86%E9%92%9F%E5%AE%9E%E7%8E%B0%E7%89%A9%E6%B5%81%E9%85%8D%E9%80%81%E9%A1%B5%E9%9D%A2%EF%BC%88%E6%97%B6%E9%97%B4%E8%BD%B4%E6%95%88%E6%9E%9C%EF%BC%89/index.html">
<meta property="og:site_name" content="乘风破浪">
<meta property="og:description" content="&gt; 物流配送页面。主要使用RecycleView实现。通过判断将条目的第一条进行特殊处理。日后复制粘贴备用。效果图如下：  可以通过各个view的相对位置来实现啊,比如那一条竖线可以用imageview来实现,那个圆点也可以用imageview实现啊,唯一不同的就是竖线的view是穿过灰色的圆view的,而position为0的竖线是不穿过蓝色的圆view的,这个也有办法搞定,在adapt">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/2533166-d7b586cf5dd2b195.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="article:published_time" content="2018-03-12T10:42:37.000Z">
<meta property="article:modified_time" content="2021-08-25T14:37:20.805Z">
<meta property="article:author" content="vchao">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="页面">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://upload-images.jianshu.io/upload_images/2533166-d7b586cf5dd2b195.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">

<link rel="canonical" href="http://vchao.top/2018/03/12/%E5%AE%89%E5%8D%93%EF%BC%9A%E4%B8%89%E5%88%86%E9%92%9F%E5%AE%9E%E7%8E%B0%E7%89%A9%E6%B5%81%E9%85%8D%E9%80%81%E9%A1%B5%E9%9D%A2%EF%BC%88%E6%97%B6%E9%97%B4%E8%BD%B4%E6%95%88%E6%9E%9C%EF%BC%89/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>安卓：三分钟实现物流配送页面（时间轴效果） | 乘风破浪</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">乘风破浪</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://vchao.top/2018/03/12/%E5%AE%89%E5%8D%93%EF%BC%9A%E4%B8%89%E5%88%86%E9%92%9F%E5%AE%9E%E7%8E%B0%E7%89%A9%E6%B5%81%E9%85%8D%E9%80%81%E9%A1%B5%E9%9D%A2%EF%BC%88%E6%97%B6%E9%97%B4%E8%BD%B4%E6%95%88%E6%9E%9C%EF%BC%89/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="vchao">
      <meta itemprop="description" content="怀揣好奇，梦想改变世界的菜鸟极客">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="乘风破浪">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          安卓：三分钟实现物流配送页面（时间轴效果）
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2018-03-12 18:42:37" itemprop="dateCreated datePublished" datetime="2018-03-12T18:42:37+08:00">2018-03-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-08-25 22:37:20" itemprop="dateModified" datetime="2021-08-25T22:37:20+08:00">2021-08-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>﻿&gt; 物流配送页面。主要使用RecycleView实现。通过判断将条目的第一条进行特殊处理。日后复制粘贴备用。效果图如下：</p>
<p><img src="https://upload-images.jianshu.io/upload_images/2533166-d7b586cf5dd2b195.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="查看物流"></p>
<p>可以通过各个view的相对位置来实现啊,比如那一条竖线可以用imageview来实现,那个圆点也可以用imageview实现啊,唯一不同的就是竖线的view是穿过灰色的圆view的,而position为0的竖线是不穿过蓝色的圆view的,这个也有办法搞定,在adapter里面单独处理,设置他们的相对位置! </p>
<h1 id="1-先做两个shape圆"><a href="#1-先做两个shape圆" class="headerlink" title="1. 先做两个shape圆"></a>1. 先做两个shape圆</h1><p>一个灰色的一个红色的。（也可以使用图片资源）<br>红色圆 logistics_shape_circle_red:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;shape xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:shape=&quot;oval&quot;&gt;</span><br><span class="line">    &lt;solid android:color=&quot;#ff4143&quot; /&gt;</span><br><span class="line">    &lt;stroke</span><br><span class="line">        android:width=&quot;2dp&quot;</span><br><span class="line">        android:color=&quot;#ff7471&quot; /&gt;</span><br><span class="line">&lt;/shape&gt;</span><br></pre></td></tr></table></figure>
<p>灰色圆 shape_circle_logistics_gray:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;shape xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:shape=&quot;oval&quot;&gt;</span><br><span class="line">    &lt;solid android:color=&quot;#dddddd&quot; /&gt;</span><br><span class="line">&lt;/shape&gt;</span><br></pre></td></tr></table></figure>
<h1 id="2-设置每个条目的布局"><a href="#2-设置每个条目的布局" class="headerlink" title="2. 设置每个条目的布局"></a>2. 设置每个条目的布局</h1><p>logistics_recycle_item.xml</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">    android:orientation=&quot;horizontal&quot;&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!--左边 时间--&gt;</span><br><span class="line">    &lt;TextView</span><br><span class="line">        android:id=&quot;@+id/tv_time&quot;</span><br><span class="line">        android:layout_width=&quot;85dp&quot;</span><br><span class="line">        android:layout_height=&quot;match_parent&quot;</span><br><span class="line">        android:layout_marginLeft=&quot;14dp&quot;</span><br><span class="line">        android:gravity=&quot;center&quot;</span><br><span class="line">        android:lines=&quot;2&quot;</span><br><span class="line">        android:text=&quot;2016-10-12 08:02:18&quot;</span><br><span class="line">        android:textColor=&quot;@color/gray9&quot;</span><br><span class="line">        android:textSize=&quot;16sp&quot; /&gt;</span><br><span class="line">    &lt;!--中间 时间轴--&gt;</span><br><span class="line">    &lt;RelativeLayout</span><br><span class="line">        android:id=&quot;@+id/rl_left&quot;</span><br><span class="line">        android:layout_width=&quot;35dp&quot;</span><br><span class="line">        android:layout_height=&quot;86dp&quot;&gt;</span><br><span class="line"></span><br><span class="line">        &lt;ImageView</span><br><span class="line">            android:id=&quot;@+id/iv_status&quot;</span><br><span class="line">            android:layout_width=&quot;20dp&quot;</span><br><span class="line">            android:layout_height=&quot;20dp&quot;</span><br><span class="line">            android:layout_centerInParent=&quot;true&quot; /&gt;</span><br><span class="line"></span><br><span class="line">        &lt;ImageView</span><br><span class="line">            android:id=&quot;@+id/iv_line&quot;</span><br><span class="line">            android:layout_width=&quot;1dp&quot;</span><br><span class="line">            android:layout_height=&quot;match_parent&quot;</span><br><span class="line">            android:layout_below=&quot;@id/iv_status&quot;</span><br><span class="line">            android:layout_centerInParent=&quot;true&quot;</span><br><span class="line">            android:src=&quot;#dddddd&quot; /&gt;</span><br><span class="line">    &lt;/RelativeLayout&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!--右边 信息--&gt;</span><br><span class="line">    &lt;TextView</span><br><span class="line">        android:id=&quot;@+id/tv_status&quot;</span><br><span class="line">        android:layout_width=&quot;match_parent&quot;</span><br><span class="line">        android:layout_height=&quot;50dp&quot;</span><br><span class="line">        android:layout_gravity=&quot;center_vertical&quot;</span><br><span class="line">        android:layout_marginRight=&quot;15dp&quot;</span><br><span class="line">        android:layout_marginTop=&quot;10dp&quot;</span><br><span class="line">        android:layout_toRightOf=&quot;@id/rl_left&quot;</span><br><span class="line">        android:autoLink=&quot;email|phone|web&quot;</span><br><span class="line">        android:text=&quot;正在派送途中,请您准备签收(派件人:张小建,电话:18513394441)&quot;</span><br><span class="line">        android:textColor=&quot;@color/gray9&quot; /&gt;</span><br><span class="line"></span><br><span class="line">    &lt;TextView</span><br><span class="line">        android:layout_width=&quot;match_parent&quot;</span><br><span class="line">        android:layout_height=&quot;1px&quot;</span><br><span class="line">        android:layout_below=&quot;@id/tv_time&quot;</span><br><span class="line">        android:layout_marginRight=&quot;10dp&quot;</span><br><span class="line">        android:layout_marginTop=&quot;5dp&quot;</span><br><span class="line">        android:layout_toRightOf=&quot;@id/rl_left&quot;</span><br><span class="line">        android:background=&quot;#9b9b9b&quot;</span><br><span class="line">        android:visibility=&quot;gone&quot; /&gt;</span><br><span class="line"></span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure>
<h1 id="3-Adapter代码"><a href="#3-Adapter代码" class="headerlink" title="3. Adapter代码"></a>3. Adapter代码</h1><p>LogisticsAdapter.xml</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br></pre></td><td class="code"><pre><span class="line">public class LogisticsAdapter0 extends RecyclerView.Adapter&lt;LogisticsAdapter0.LogisticsAdapterHolder&gt; &#123;</span><br><span class="line"></span><br><span class="line">    private Context context;</span><br><span class="line">    private LayoutInflater mLayoutInflater;</span><br><span class="line">    private LogisticsJson bean;</span><br><span class="line">    </span><br><span class="line">    public LogisticsAdapter0(Context context, LogisticsJson bean) &#123;</span><br><span class="line">        this.context = context;</span><br><span class="line">        this.mLayoutInflater = LayoutInflater.from(context);</span><br><span class="line">        this.bean = bean;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    public int getItemCount() &#123;</span><br><span class="line">        return bean.getData().getList().size();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    public LogisticsAdapter0.LogisticsAdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) &#123;</span><br><span class="line">        return new LogisticsAdapter0.LogisticsAdapterHolder(mLayoutInflater.inflate(R.layout.logistics_recycle_item, parent, false));</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    public void onBindViewHolder(LogisticsAdapter0.LogisticsAdapterHolder holder, int position) &#123;</span><br><span class="line"></span><br><span class="line">        try &#123;</span><br><span class="line">            holder.tv_status.setText(bean.getData().getList().get(position).getContext());//订单状态</span><br><span class="line">            holder.tv_time.setText(bean.getData().getList().get(position).getTime());//时间</span><br><span class="line"></span><br><span class="line">            if (position == 0) &#123;</span><br><span class="line">                //红色的圆点</span><br><span class="line">                holder.iv_status.setImageResource(R.drawable.logistics_shape_circle_red);</span><br><span class="line">                RelativeLayout.LayoutParams pointParams = new RelativeLayout.LayoutParams(DensityUtil.dp2px(context, 20), DensityUtil.dp2px(context, 20));</span><br><span class="line">                pointParams.addRule(RelativeLayout.CENTER_IN_PARENT);</span><br><span class="line">                holder.iv_status.setLayoutParams(pointParams);</span><br><span class="line"></span><br><span class="line">                holder.tv_time.setTextColor(context.getResources().getColor(R.color.newPrimary));</span><br><span class="line">                holder.tv_status.setTextColor(context.getResources().getColor(R.color.newPrimary));</span><br><span class="line"></span><br><span class="line">                //灰色的竖线</span><br><span class="line">                RelativeLayout.LayoutParams lineParams = new RelativeLayout.LayoutParams(DensityUtil.dp2px(context, 1), ViewGroup.LayoutParams.MATCH_PARENT);</span><br><span class="line">                lineParams.addRule(RelativeLayout.BELOW, R.id.iv_status);//让直线置于圆点下面</span><br><span class="line">                lineParams.addRule(RelativeLayout.CENTER_IN_PARENT);</span><br><span class="line">                holder.iv_line.setLayoutParams(lineParams);</span><br><span class="line"></span><br><span class="line">            &#125; else &#123;</span><br><span class="line">//                holder.iv_status.setBackgroundResource(R.mipmap.ic_logistics_bottom);</span><br><span class="line">                holder.iv_status.setImageResource(R.drawable.logistics_shape_circle_gray);</span><br><span class="line">                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(DensityUtil.dp2px(context, 10), DensityUtil.dp2px(context, 10));</span><br><span class="line">                lp.addRule(RelativeLayout.CENTER_IN_PARENT);</span><br><span class="line"></span><br><span class="line">                holder.iv_status.setLayoutParams(lp);</span><br><span class="line"></span><br><span class="line">                holder.tv_time.setTextColor(context.getResources().getColor(R.color.textColor_9b));</span><br><span class="line">                holder.tv_status.setTextColor(context.getResources().getColor(R.color.textColor_9b));</span><br><span class="line"></span><br><span class="line">                //灰色的竖线</span><br><span class="line">                RelativeLayout.LayoutParams lineParams = new RelativeLayout.LayoutParams(DensityUtil.dp2px(context, 1), ViewGroup.LayoutParams.MATCH_PARENT);</span><br><span class="line">//                lineParams.addRule(RelativeLayout.BELOW, R.id.iv_status);//让直线置于圆点下面</span><br><span class="line">                lineParams.addRule(RelativeLayout.CENTER_IN_PARENT);</span><br><span class="line">                holder.iv_line.setLayoutParams(lineParams);</span><br><span class="line"></span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125; catch (Exception e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    //自定义的ViewHolder，持有每个Item的的所有界面元素</span><br><span class="line">    public static class LogisticsAdapterHolder extends RecyclerView.ViewHolder &#123;</span><br><span class="line"></span><br><span class="line">        ImageView iv_status;</span><br><span class="line">        TextView tv_status;</span><br><span class="line">        TextView tv_time;</span><br><span class="line">        ImageView iv_line;</span><br><span class="line"></span><br><span class="line">        LogisticsAdapterHolder(View view) &#123;</span><br><span class="line">            super(view);</span><br><span class="line">            iv_line = (ImageView) view.findViewById(R.id.iv_line);</span><br><span class="line">            iv_status = (ImageView) view.findViewById(R.id.iv_status);</span><br><span class="line">            tv_status = (TextView) view.findViewById(R.id.tv_status);</span><br><span class="line">            tv_time = (TextView) view.findViewById(R.id.tv_time);</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="4-最后，Activity里面设置一下"><a href="#4-最后，Activity里面设置一下" class="headerlink" title="4. 最后，Activity里面设置一下"></a>4. 最后，Activity里面设置一下</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">LogisticsJson logisticsJson = new Gson().fromJson(json, LogisticsJson.class);</span><br><span class="line">LogisticsAdapter logisticsAdapter = new LogisticsAdapter(LogisticsActivity.this, logisticsJson);</span><br><span class="line">rvLogisticsDetail.setAdapter(logisticsAdapter);</span><br></pre></td></tr></table></figure>


<p>再给一个测试的json，自己生成Gson 的bean类吧！</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    &quot;code&quot;: 1,</span><br><span class="line">    &quot;message&quot;: &quot;Success&quot;,</span><br><span class="line">    &quot;data&quot;: &#123;</span><br><span class="line">        &quot;id&quot;: &quot;1&quot;,</span><br><span class="line">        &quot;state&quot;: &quot;3&quot;,</span><br><span class="line">        &quot;num&quot;: &quot;71265042088396&quot;,</span><br><span class="line">        &quot;time&quot;: &quot;2018-03-11 12:55:09&quot;,</span><br><span class="line">        &quot;com_name&quot;: &quot;汇通&quot;,</span><br><span class="line">        &quot;list&quot;: [</span><br><span class="line">            &#123;</span><br><span class="line">                &quot;time&quot;: &quot;2018-03-02 08:46:40&quot;,</span><br><span class="line">                &quot;context&quot;: &quot;秦皇岛市|秦皇岛市【秦皇岛市区五部】，八栋西霞超市 已签收&quot;</span><br><span class="line">            &#125;， &#123;</span><br><span class="line">                &quot;time&quot;: &quot;2018-03-02 08:46:40&quot;,</span><br><span class="line">                &quot;context&quot;: &quot;秦皇岛市|秦皇岛市【秦皇岛市区五部】，八栋西霞超市 已签收&quot;</span><br><span class="line">            &#125;</span><br><span class="line">        ]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>大功告成！复制粘贴大法好~~</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Android/" rel="tag"># Android</a>
              <a href="/tags/%E9%A1%B5%E9%9D%A2/" rel="tag"># 页面</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2017/05/12/AS%E9%83%A8%E7%BD%B2%E5%A4%B1%E8%B4%A5%EF%BC%8CDevice%20supports,but%20APK%20only%20supports.../" rel="prev" title="AS部署失败，Device supports,but APK only supports...">
      <i class="fa fa-chevron-left"></i> AS部署失败，Device supports,but APK only supports...
    </a></div>
      <div class="post-nav-item">
    <a href="/2018/03/19/%E5%AE%89%E5%8D%93%EF%BC%9A%E4%BB%8E%E7%BD%91%E9%A1%B5%E5%94%A4%E9%86%92APP/" rel="next" title="安卓：从网页唤醒APP">
      安卓：从网页唤醒APP <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-%E5%85%88%E5%81%9A%E4%B8%A4%E4%B8%AAshape%E5%9C%86"><span class="nav-number">1.</span> <span class="nav-text">1. 先做两个shape圆</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-%E8%AE%BE%E7%BD%AE%E6%AF%8F%E4%B8%AA%E6%9D%A1%E7%9B%AE%E7%9A%84%E5%B8%83%E5%B1%80"><span class="nav-number">2.</span> <span class="nav-text">2. 设置每个条目的布局</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-Adapter%E4%BB%A3%E7%A0%81"><span class="nav-number">3.</span> <span class="nav-text">3. Adapter代码</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#4-%E6%9C%80%E5%90%8E%EF%BC%8CActivity%E9%87%8C%E9%9D%A2%E8%AE%BE%E7%BD%AE%E4%B8%80%E4%B8%8B"><span class="nav-number">4.</span> <span class="nav-text">4. 最后，Activity里面设置一下</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">vchao</p>
  <div class="site-description" itemprop="description">怀揣好奇，梦想改变世界的菜鸟极客</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">46</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">冀ICP备 17022751号-1 </a>
      <img src="https://beian.miit.gov.cn" style="display: inline-block;">
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">vchao</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
